package net;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class TcpClientTest2 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9999);
        Scanner scanner = new Scanner(System.in);

        OutputStream outputStream = socket.getOutputStream();

        while (true) {
            String line = scanner.nextLine();
            if (line.length() == 0) break;
            outputStream.write(line.getBytes(StandardCharsets.UTF_8));
            outputStream.flush();
        }

        socket.close();

    }
}
